import axios from 'axios';
import {API_NEW_VERSION} from '../api';
let qs = require('qs');

export const searchResouces = params => {
  return axios.get(API_NEW_VERSION + 'resources', {params: params});
};

export const saveResouce = params => {
  return axios.post(API_NEW_VERSION + 'resources', params);
};

export const buildResouceQuery = (id, clazz) => {
  return axios.post(API_NEW_VERSION + 'resources/' + id, qs.stringify({clazz: clazz}));
};

export const deleteResouces = ids => {
  return axios.delete(API_NEW_VERSION + 'resources/' + ids);
};

export const resourceTree = (filters = '') => {
  return axios.get(API_NEW_VERSION + 'resources/tree', {params: {filters: filters}});
};
